package expansion.sort;

import java.lang.reflect.Array;
import java.util.Arrays;

public class ShellSort {
    public static void main(String[] args) {
        int[] arr = {34,13,22,6};
        for (int gap = arr.length/2; gap >=1 ; gap/=2) {//gap=2
            for (int i = gap; i < arr.length; i++) {//i=2
                int temp = arr[i];//temp=22
                int j;
                for (j = i-gap; j >= 0 && arr[j]>temp; j-=gap) {//j=0;arr[0]=34>22-->true;
                    arr[j+gap] = arr[j];//arr[2]=34
                }
                arr[j+gap] = temp;

            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
